﻿using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using ReportWizard.Properties;

namespace ReportWizard.Controls
{
    class CustomCheckBox : CheckBox
    {
        private readonly Brush _backgroundBrushUnchecked = new TextureBrush(Resources.Check_icon18_unchecked);
        private readonly Brush _backgroundBrushChecked = new TextureBrush(Resources.Check_icon18);

        [Localizable(false)]
        public override sealed string Text
        {
            get { return base.Text; }
            set { base.Text = string.Format("  {0}", value); }
        }

        public CustomCheckBox()
        {
            Width = 18;
            Height = 18;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            
            RectangleF rectangle = new RectangleF(e.Graphics.ClipBounds.X, e.Graphics.ClipBounds.Y, 18F, 18F);
            e.Graphics.FillRectangle(Checked ? _backgroundBrushChecked : _backgroundBrushUnchecked, rectangle);
        }
    }
}
